package com.example.administrator.androidui7;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class Activity01 extends AppCompatActivity {
    Button mBtn1;
TextView mTvmessage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_01);

    mBtn1 = findViewById(R.id.btn_button1);
    mTvmessage = findViewById(R.id.tv_message);
    mBtn1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Activity01.this,Activity02.class);
        startActivityForResult(intent,100);
        }
    });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode==100){
            if(resultCode==1002) {
                String message = data.getStringExtra("date");
                mTvmessage.setText(message);
            }
        }
    }
}
